package edu.ccut.saturn.basecomponent.database.impl.db2;

import edu.ccut.saturn.basecomponent.database.IDatabaseAttribute;

public class DB2Attribute implements IDatabaseAttribute {
	// 整数
	public static final String BIGINT = "BIGINT";

	public static final String INTEGER = "INTEGER";

	public static final String SMALLINT = "SMALLINT";

	public static final String INT = "INT";

	// 浮点数

	// BigDecimal
	public static final String DECIMAL = "DECIMAL";

	public static final String DEC = "DEC";

	public static final String NUMERIC = "NUMERIC";

	public static final String NUM = "NUM";

	// float
	public static final String REAL = "REAL";

	// double
	public static final String DOUBLE = "DOUBLE";

	public static final String DOUBLE_PRECISION = "DOUBLE_PRECISION";

	public static final String FLOAT = "FLOAT";

	// 时间
	public static final String DATE = "DATE";

	public static final String TIME = "TIME";

	public static final String TIMESTAMP = "TIMESTAMP";

	// 字符数据
	public static final String CHARACTER = "CHARACTER";

	public static final String CHAR = "CHAR";

	public static final String CHARACTER_VARYING = "CHARACTER_VARYING";

	public static final String CHAR_VARYING = "CHAR_VARYING";

	public static final String VARCHAR = "VARCHAR";

	public static final String LONG_VARCHAR = "LONG_VARCHAR";

	public static final String CLOB = "CLOB";

	// 图形字符串
	public static final String GRAPHIC = "GRAPHIC";

	public static final String VARGRAPHIC = "VARGRAPHIC";

	public static final String LONG_VARGRAPHIC = "LONG_VARGRAPHIC";

	public static final String DBCLOB = "DBCLOB";

	// 二进制字符数据
	public static final String BLOB = "BLOB";

	// 下面的不知道是什么
	public static final String DATALINK = "DATALINK";

	public static final String REFERENCE = "REFERENCE";

	/**
	 * single quote mark
	 * 
	 * @param type
	 * @return 如果type是数字类型返回"",否则返回"'"
	 */
	public static String quote(String type) {
		if (BIGINT.equals(type) || INTEGER.equals(type) || DOUBLE.equals(type)
				|| DECIMAL.equals(type) || REAL.equals(type)
				|| SMALLINT.equals(type)) {
			return "";
		} else {
			return "'";
		}
	}

	/**
	 * 是否是数字类型
	 * 
	 * @return
	 */
	public boolean isNumber(String type) {
		if (DECIMAL.equalsIgnoreCase(type) || INTEGER.equalsIgnoreCase(type)
				|| BIGINT.equalsIgnoreCase(type)
				|| SMALLINT.equalsIgnoreCase(type)
				|| REAL.equalsIgnoreCase(type) || DOUBLE.equalsIgnoreCase(type)
				|| DECIMAL.equalsIgnoreCase(type)) {
			return true;
		}
		return false;
	}

	/**
	 * 是否是大数据类型
	 * 
	 * @param type
	 * @return
	 */
	public boolean isLOB(String type) {
		if (BLOB.equalsIgnoreCase(type) || CLOB.equalsIgnoreCase(type)
				|| DBCLOB.equalsIgnoreCase(type)) {
			return true;
		}
		return false;
	}
}
